package com.photoeditor.demo.util;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;

public class CameraDrawable extends BitmapDrawable{
	
	public CameraDrawable(Bitmap bitmap) {
		super(bitmap);
	}
	
	public CameraDrawable(Resources resources, Bitmap bitmap) {
		super(resources, bitmap);
	}
	
	/**
	 * 回收Bitmap
	 */
	public void recycle() {
		Bitmap bitmap = getBitmap();
		if (bitmap != null && !bitmap.isRecycled()) {
			bitmap.recycle();
		}
	}
	
	/**
	 * 防止异常发生
	 */
	@Override
	public void draw(Canvas canvas) {
		Bitmap bitmap = getBitmap();
		if (bitmap != null && !bitmap.isRecycled()) {
			super.draw(canvas);
		}
	}
	
}
